home *** CD-ROM | disk | FTP | other *** search
- /*
- data structures for pdl (packet descriptor langage
-
- */
- #ifndef eextern
- #define eextern extern
- #endif
- #include "xsetjmp.h" /*setjmp.h + protypes*/
-
- void pr_error(char *);
-
- typedef struct {
- uint32 nd_print:4, /*how to print*/
- nd_resv1:11, /*unused, reserved for expansion*/
- nd_indreg:5, /*indirect (value) register*/
- nd_lodreg:5, /*load field value into this register*/
- nd_indsize:1, /*size is indirect (nd_size is register)*/
- nd_size:6; /*item size*/
- }nd_fvalue; /*what the value field of a 'field'*/
-
- /*
- nd_print values
- */
- #define HEX 0x00000000 /*print field in hex*/
- #define DEC 0x10000000 /*print field in decimal*/
- #define NOPRINT 0x20000000 /*don't print at all*/
- #define CNT_STR 0x30000000 /*print a counted ascii string*/
- #define IP_ADR 0x40000000 /*an ip address*/
-
- /*map the above fake names into real values*/
- #define PR_REAL(xxx) ((xxx)>>28)
-
- #define VIND(xxx) ((xxx)<<12) /*load value inderectly*/
- #define VLOAD(xxx) ((xxx)<<7) /*store value into a register*/
-
- #define SIND(xxx) (0x40|(xxx)) /*load a size inderectly*/
-
- #define PDL_REG_MAX 31 /*the maximum register number*/
-
- /*
- define a bit field
- */
- void pdl_field(uint32,char *);
- #define field(fld_name,fld_size,fld_radix) \
- pdl_field(fld_radix|fld_size,fld_name);
-
- /*
- name a bit pattern
- */
- #define name(nam_name,nam_value) \
- if(ppg.pr_last_value==(nam_value)) { /*match last field value?*/ \
- /*our value matched the last 'field' value so print our name*/ \
- OUT_str("("); \
- OUT_str(nam_name); \
- OUT_str(")"); }
-
- /*
- define a sub protocol
- */
- #define protocol(prot_name,prot_adr,prot_value,reg) \
- if(ppg.pr_last_value==(prot_value)) { /*match last field value?*/ \
- /*our value matched the last 'field' value so print our name*/ \
- OUT_str("("); \
- OUT_str(prot_name); \
- OUT_str(")"); \
- /*remember the address of our protocol handler for later*/ \
- ppg.pr_regs[reg]=(uint32)&prot_adr; \
- }
-
- #define loop_till_end(lc_routine) \
- while(ppg.pr_size>0) \
- lc_routine();
-
- #define loop_count(loop_reg,lc_routine) \
- {long count; \
- count=ppg.pr_regs[loop_reg]; /*get the repeat count*/ \
- while((--count) >= 0) /*loop the specified number of times*/ \
- lc_routine(); \
- }
-
- #define pdl_begin(xxxx) \
- void xxxx(void); \
- void xxxx(){
- /*pdlbegin for routines that are already prototyped (by pdl_extern)*/
- #define pdl_begin_forward(xxxx) \
- void xxxx(){
-
-
- #define pdl_extern(xxxx) extern void xxxx(void);
-
- #define pdl_end }
-
- #define thats_all if(ppg.pr_size>0)pr_error("??excess data");
-
- #define pdl_indirect_gosub(reg) \
- {void (*sp_rtn)(); \
- sp_rtn=(void (*)())ppg.pr_regs[reg]; \
- if(sp_rtn!=NIL) (*sp_rtn)(); \
- }
-
- #define pdl_gosub(pdl_go) \
- pdl_go();
-
- #define pdl_special(pdl_go) \
- pdl_go(&ppg);
-
- #define pdl_zero(reg) ppg.pr_regs[reg]=0;
-
- void pdl_print(uint8 *,void (*)(),uint16);
-
- /*
- interpretor globals for special functions to use
- */
-
- #define BITS_PER_DATA 8 /*how big a data item is*/
- #define DATA_IS uint8 /*change to uint16 if all packets word aligned*/
-
- typedef struct {
- uint32 pr_last_value; /*last field value*/
- uint32 pr_size; /*bits left to use in data packet*/
- uint8 pr_curb; /*current bit position for reading data*/
- DATA_IS *pr_data; /*pointer to data*/
- uint32 pr_regs[PDL_REG_MAX+1]; /*the pdl registers*/
- jmp_buf pr_jmp_buf; /*error throw for pdl errors*/
- } pdl_pr_dat,*pdl_pr_dat_pt;
-
- eextern pdl_pr_dat ppg; /*pdl print globals*/
-
- /*
- name pdl registers
- */
- #define t0 1 /*a temporary*/
- #define t1 2
- #define ddp_type 3 /*ddp type (loaded for both short and long ddps)*/
- #define proto 4 /*holds protocol gosub address*/
- #define zipcount 5 /*zone info protocol repeat count*/
- #define ip_type 6 /*ip packet type*/
-